function quickSort(arr){
    if(arr.length<=1){
        return arr
    }
    let left=[]
    let right=[]
    let queue=[]
    let mid=Math.floor(arr.length/2)
    let midNum=arr[mid]

    for(let i=0;i<arr.length;i++){
        if(arr[i]<midNum){
            left.push(arr[i])
        }
        else if(arr[i]>midNum){
            right.push(arr[i])
        }
        else if(arr[i]===midNum){
            queue.push(arr[i])
        }
    }

    return[...quickSort(left),...queue,...quickSort(right)]
}